﻿<UserControl x:Class="TerraMap.ExceptionControl" x:Name="exceptionControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
				 xmlns:sys="clr-namespace:System;assembly=mscorlib"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="200"
				 Padding="6"
				 d:DataContext="{d:DesignInstance sys:Exception}">
	<UserControl.Resources>
		<Style TargetType="TextBlock">
			<Setter Property="Margin" Value="0" />
		</Style>
	</UserControl.Resources>

	<UserControl.CommandBindings>
		<CommandBinding Command="ApplicationCommands.Copy" CanExecute="OnCopyCommandCanExecute" Executed="OnCopyCommandExecuted" />
	</UserControl.CommandBindings>
	<UserControl.InputBindings>
		<KeyBinding Command="ApplicationCommands.Copy" Gesture="Ctrl+C" />
	</UserControl.InputBindings>
	<Grid x:Name="LayoutRoot" Margin="2">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>

		<TextBlock Grid.Row="0" Margin="2" FontWeight="Bold" Text="{Binding Heading}" />
		<TextBlock Grid.Row="1" Margin="12,2,2,2" Text="{Binding Message}" TextWrapping="Wrap" />
		<Expander Grid.Row="2" Margin="2" IsExpanded="False" Visibility="{Binding Path=DetailsVisibility}">
			<Expander.Header>
				<TextBlock Text="Details" TextWrapping="Wrap" />
			</Expander.Header>
			<Expander.Content>
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="*" />
						<RowDefinition Height="Auto" />
					</Grid.RowDefinitions>
					<TextBox IsReadOnly="True" Text="{Binding Path=Exception, Mode=OneWay}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Margin="2" />
					<TextBlock Grid.Row="1" Visibility="{Binding InfoVisibility, FallbackValue=Collapsed}">
						<Run>Version:</Run>
						<Run Text="{Binding Info}" />
					</TextBlock>
				</Grid>
			</Expander.Content>
		</Expander>

		<Button Content="C_lose" Command="ApplicationCommands.Close" MinWidth="75" MinHeight="23" HorizontalAlignment="Right" Margin="2" Grid.Row="3" 
				  Visibility="{Binding Path=CancelButtonVisibility, ElementName=exceptionControl}"  />
		<Button Content="_Copy Details" Command="ApplicationCommands.Copy" MinWidth="75" MinHeight="23" HorizontalAlignment="Left" Margin="2" Grid.Row="3" Visibility="{Binding Path=DetailsVisibility}" />
	</Grid>
</UserControl>